package com.blog.security.security;

import com.blog.util.utils.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author chenlin
 * @create 2021-03-18  14:17
 */
public class DefaultPasswordEncoder implements PasswordEncoder {
    public DefaultPasswordEncoder(int a) {

    }

    public DefaultPasswordEncoder() {
        this(-1);
    }
    //进行md5加密
    @Override
    public String encode(CharSequence charSequence) {
        return MD5.encrypt(charSequence.toString());

    }
    //进行密码比对
    @Override
    public boolean matches(CharSequence charSequence, String s) {
        return s.equals(MD5.encrypt(charSequence.toString()));
    }
}
